/**
 * made in 2007-11-2上午02:32:47
 * 唉 你丫真二 
 */
package com.litxuf.web.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.litxuf.FinalInformation;
import com.litxuf.logic.admin.dao.model.UserAdmin;

/**
 * @author xufeng
 *  
 */
public class AdminLoginFilter implements Filter {
	Logger logger = Logger.getLogger(this.getClass().getName());
	public void init(FilterConfig arg0) throws ServletException {
		
	}

	public void doFilter(ServletRequest re, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) re;
		HttpServletResponse response = (HttpServletResponse) res;
		
		request.setCharacterEncoding("utf-8");
		
		UserAdmin login=(UserAdmin)request.getSession().getAttribute(FinalInformation.UserAdiminOperator);
		if(login==null){
			logger.info("--> 未登录 返回登录页面 ---"+request.getContextPath());
			response.sendRedirect(request.getContextPath()+"/2008/2088.jsp");
			return ;
		}else{
// 			logger.info("----0----");
			}
		filterChain.doFilter(re, res);
		
		
	}
	public void destroy() {
		
	}

}
